﻿using System;
using NUnit.Framework;
using NUnit.Framework.Constraints;
using NUnit.Framework.SyntaxHelpers;
using Yaml.Presentation.Parsing;
using Yaml.Presentation.Tokens;

namespace Yaml.Tests.Presentation.ScannerTests {
    [TestFixture]
    public class Mappings {
        [Test]
        public void BlockMapping() {
            Scanner s = Helper.CreateScanner("? \n: ");
            Token t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<StreamStartToken encoding='utf-8' start={0:0,0} end={0:0,0}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockMappingStartToken indent='0' start={0:0,0} end={0:0,0}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<MappingKeyToken start={0:0,0} end={1:0,1}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<MappingValueToken start={3:1,0} end={4:1,1}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockEndToken indent='-1' start={5:1,2} end={5:1,2}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<StreamEndToken start={5:1,2} end={5:1,2}>"));
        }
        [Test]
        public void FlowMapping() {
            Scanner s = Helper.CreateScanner("{? : }");
            Token t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<StreamStartToken encoding='utf-8' start={0:0,0} end={0:0,0}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<FlowMappingStartToken flowDepth='1' start={0:0,0} end={1:0,1}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<MappingKeyToken start={1:0,1} end={2:0,2}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<MappingValueToken start={3:0,3} end={4:0,4}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<FlowMappingEndToken flowDepth='0' start={5:0,5} end={6:0,6}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<StreamEndToken start={6:0,6} end={6:0,6}>"));
        }
    }
}
